/*用户类型*/
function formatterDemandFun(value,row,index){
	
		if (row.dstatus == "end" ) {
			
			return '<button class="btn btn-primary " type="button"  onclick="totabss(\''+basePath+'/myDemandManager/autDemandInfo.do?id='+row.id+'\',\'认证订单管理(订单编号'+row.demandId+')\')"><i class="fa fa-paste"></i>查看详情</button>'
			
	    }else{
	    	
	    	return '<button class="btn btn-primary " type="button"  onclick="totabss(\''+basePath+'/myDemandManager/autDemandInfo.do?id='+row.id+'\',\'认证订单管理(订单编号'+row.demandId+')\')"><i class="fa fa-paste"></i>编辑信息</button>'+
	    	' <button class="btn btn-primary " type="button"  onclick="confirmPage(\''+row.id+'\',\''+row.demandId+'\',\''+row.dType+'\',\''+row.dTypeContext+'\',\''+row.demandTitle+'\')"><i class="fa fa-paste"></i>重新发送</button>'
	    }
}

function totabss(href,txt) {
	window.parent.addTable(href,txt);
}

//渲染需求状态
function renderDemandStatus(value,row,index)
{
	var temp='<label class="label {0}">{1}</label>';
	
    if (value == "end" && (row.toConfrim =='0' || row.toConfrim =='1')) {
    	return temp.format("label-success","停止响应"); 
    }
    if (value === "chatting" ) {
    	return temp.format("label-warning","洽谈中");
    }
    if (value == "end" && (row.toConfrim =='4' ) ) {
    	return temp.format("label-danger","已结束(无人响应)");
    }
    if (value == "end" && (row.toConfrim =='2' ) ) {
    	return temp.format("label-default","已结束(未成交)");
    }	
    if (value == "end" && ( row.toConfrim =='3') ) {
    	return temp.format("label-primary","已结束(已成交)");
    }	
    
    return temp.format("label-danger",row.toConfrim+'+'+value);
}

//渲染成交状态
function renderDemandConfirm(value,row,index) {
	
	var temp='<input type="hidden" value="{0}"><label class="label {1}">{2}</label>';
	
	if (value === '0') {
		
		return temp.format(value,"label-default","初始"); 
		
	}

	if (value === '1') {
		
		return temp.format(value,"label-info","待确认");
	
	}

	if (value === '2') {
	
		return temp.format(value,"label-warning","未成交");
	}

	if (value === '3') {
	
		return temp.format(value,"label-success","已成交");
	
	}
	if (value === '4') {
		
		return temp.format(value,"label-danger","无人响应");
	
	}
	return temp.format(value,"label-danger","未知");
}

//渲染激活状态
function renderDemandActive(data,row,index)
{
	var temp='<input type="hidden" value="{0}"><label class="label {1}">{2}</label>';

	if (data === '0') {
		return temp.format(data,"label-warning","否"); 
	}

	if (data === '1') {
		return temp.format(data,"label-success","是");
	}
	
	return temp.format(data,"label-danger","未知");

}

//渲染激活状态
function renderDemandLevel(data,row,index)
{
	var temp='<input type="hidden" value="{0}"><label class="label {1}">{2}</label>';

	if (data === 'ordinary') {
		return temp.format(data,"label-success","普通"); 
	}

	if (data === 'authentication') {
		return temp.format(data,"label-warning","认证（自营）");
	}
	
	if (data === 'mediacy') {
		return temp.format(data,"label-danger","认证（居间）");
	}
	
	return temp.format(data,"label-danger","未知");

}


//渲染需求状态
function quotationIsActivated(value,row,index)
{
	var temp='<label class="label {0}">{1}</label>';
	
    if (value === "1" ) {
    	return temp.format("label-primary","已报价");
    }
    if (value === "0"  ) {
    	return temp.format("label-warning","未报价");
    }	
    if (value === "2"  ) {
    	return temp.format("label-danger","已作废");
    }
    
    return temp.format("label-danger","未知");
}

//渲染需求状态
function quotationStatus(value,row,index)
{
	var temp='<label class="label {0}">{1}</label>';
	
    if (value === "offer" ) {
    	return temp.format("label-primary","洽谈中");
    }
    if (value === "yesdeal"  ) {
    	return temp.format("label-warning","已成交");
    }	
    if (value === "nodeal"  ) {
    	return temp.format("label-danger","未成交");
    }
}

function userFormatter(value,row,index){
	
	return row.regName+"("+row.telephone+")-"+row.company
}

function  renderCenter(data,row,index) {
	
	var temp ="";
	
	if(row.quotationStatus === 'offer'){
		
		temp = '<a class="btn btn-sm btn-info" onClick=javascript:setConfirm(\''+row.quotationId+'\',\'yesdeal\')>成交</a> <a class="btn btn-sm btn-warning" onClick=javascript:setConfirm(\''+row.quotationId+'\',\'nodeal\')>不成交</a>'
	}

	if(row.quotationIsActivated === "1"){
		temp = temp+' <a class="btn btn-sm btn-success" onClick="edit(\'报价单详情\',\'95%\',\'95%\',\'<%=basePath%>/quotation/quotationInfo.do?id='+row.quotationId+'&source=info'+'&demandId='+$("#demandId").val()+'\')")>查询报价单</a>'
	}
	
	return temp;
}


//渲染需求状态
function renderPerformance(value,row,index)
{
	var temp='<label class="label {0}">{1}</label>';
	
    if (value === "0" ) {
    	return temp.format("label-warning","未开始");
    }
    if (value === "1" ) {
    	return temp.format("label-danger","履行中");
    }
    if (value === "2"  ) {
    	return temp.format("label-default","合同异常");
    }	
    if (value === "3"  ) {
    	return temp.format("label-success","合同接触");
    }	
    if (value == "4"  ) {
    	return temp.format("label-primary","已完成");
    }
    
    return temp.format("label-danger","未知");
}
//渲染激活状态
function renderContractType(data,row,index)
{
	var temp='<input type="hidden" value="{0}"><label class="label {1}">{2}</label>';

	if (data === 'ZYB') {
		return temp.format(data,"label-warning","自营采购"); 
	}

	if (data === 'ZYS') {
		return temp.format(data,"label-success","自营销售");
	}
	
	if (data === 'J') {
		return temp.format(data,"label-info","居间");
	}
	
	return temp.format(data,"label-danger","未知");

}

//渲染需求状态
function renderSubscribe(value,row,index)
{
	var temp='<label class="label {0}">{1}</label>';
	
    if (value === "0" ) {
    	return temp.format("label-warning","不签合同");
    }
    if (value === "1" ) {
    	return temp.format("label-danger","未签合同");
    }
    if (value === "2"  ) {
    	return temp.format("label-default","我方已签");
    }	
    if (value === "3"  ) {
    	return temp.format("label-primary","双方已签");
    }	
    if (value === "4"  ) {
    	return temp.format("label-danger","作废");
    }
    
    return temp.format("label-danger","未知");
}

/*用户类型*/
function formatterContractFun(value,row,index){
	return '<a class="btn btn-primary " type="button" onclick="edit(\'合同详情\',\'95%\',\'95%\',\''+basePath+'/contract/ContractInfoPage.do?id='+row.id+'\')"><i class="fa fa-paste"></i> 合同详情</a>'
}


//渲染成交状态
function renderResponseConfirm(data) {
	
	var temp='<input type="hidden" value="{0}"><label class="label {1}">{2}</label>';
	
	if (data === '0') {
		
		return temp.format(data,"label-default","初始"); 
		
	}

	if (data === '1') {
		
		return temp.format(data,"label-info","待确认");
	
	}

	if (data === '2') {
	
		return temp.format(data,"label-warning","未成交");
	}

	if (data === '3') {
	
		return temp.format(data,"label-success","已成交");
	
	}
	if (data === '4') {
		
		return temp.format(data,"label-danger","无人响应");
	
	}
	return temp.format(data,"label-danger","未知");
}


